<p>This is an issue when checking array length before calling <code>Array#some()</code> or <code>Array#every()</code> methods in cases where the
length check is redundant.</p>
<h2>Why is this an issue?</h2>
<p>JavaScript’s <code>Array#some()</code> and <code>Array#every()</code> methods already handle empty arrays correctly without requiring explicit
length checks.</p>
<p>The <code>Array#some()</code> method returns <code>false</code> when called on an empty array because no elements can satisfy the condition.
Similarly, <code>Array#every()</code> returns <code>true</code> for empty arrays following the principle of vacuous truth - if there are no elements,
then technically all elements satisfy the condition.</p>
<p>When developers add unnecessary length checks before these method calls, it creates redundant code that:</p>
<ul>
  <li> Makes the code longer and harder to read </li>
  <li> Suggests a misunderstanding of how these array methods work </li>
  <li> Can confuse other developers about the actual behavior of the code </li>
  <li> Adds unnecessary complexity to logical expressions </li>
</ul>
<p>The redundant patterns typically look like <code>array.length === 0 || array.every(…​)</code> or <code>array.length !== 0 &amp;&amp;
array.some(…​)</code>. In both cases, the length check doesn’t change the final result because the array methods already handle empty arrays
appropriately.</p>
<h3>What is the potential impact?</h3>
<p>This issue primarily affects code readability and maintainability. While it doesn’t cause functional bugs, it can lead to confusion among team
members and makes the codebase unnecessarily verbose. Removing these redundant checks results in cleaner, more idiomatic JavaScript code that better
expresses the developer’s intent.</p>
<h3>How to fix?</h3>
<p>Remove the redundant length check when using <code>Array#every()</code> with OR logic. The <code>every()</code> method already returns
<code>true</code> for empty arrays.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
if (array.length === 0 || array.every(Boolean)) { // Noncompliant
  // Handle case
}
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
if (array.every(Boolean)) {
  // Handle case
}
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/no-useless-length-check.md">no-useless-length-check</a> </li>
  <li> MDN - Array.prototype.some() - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some">Official
  documentation for the Array.some() method</a> </li>
  <li> MDN - Array.prototype.every() - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every">Official
  documentation for the Array.every() method</a> </li>
</ul>
